﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using FwProject.Distribution.Dto
@using X.PagedList.Mvc.Common;
@model IPagedList<ReceivableSummaryListDto>
@{
    Layout = null;
    decimal SumtotalPrice = 0;
    int count = 0;
    int i = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {

            i = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
}
<div id="table_print" style="max-height:600px;overflow-y:scroll;">
    @if (Model.Count == 0)
    {
        <h4>暂无数据</h4>
    }
    else
    {
        <table class="table table-bordered table-hover table-rowselected" >
            <thead>
                <tr>
                    <th style="width:45px">序号</th>
                    <th>餐厅名称</th>
                    <th>配送金额</th>
                    <th>总优惠</th>
                    <th>应收金额</th>
                    <th>未收金额</th>
                    <th>货品型号</th>
                    <th>配送箱数</th>
                    <th>配送数量</th>
                    <th>回收箱数</th>
                    <th>回收数量</th>
                    <th>赠送箱数</th>
                    <th>赠送数量</th>
                    <th>换货箱数</th>
                    <th>换货数量</th>
                    <th>退回箱数</th>
                    <th>退回数量</th>
                    <th>折损数量</th>
                    <th>单价</th>
                    <th>金额</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    i++;
                    count = item.TypeNumberList.Count;
                    if (count > 0)
                    {
                        for (int x = 0; x < item.TypeNumberList.Count; x++)
                        {
                            <tr>
                                @if (x == 0)
                                {
                                    <td rowspan="@count">@i</td>
                                    <td rowspan="@count">@item.RestaurantName</td>
                                    <td rowspan="@count">@item.DistributionPrice</td>
                                    <td rowspan="@count">@item.SumDiscountprice</td>
                                    <td rowspan="@count">@item.TotalPrice</td>
                                    <td rowspan="@count">@item.UncollectedPrice</td>
                                    <td>@item.TypeNumberList[x].TypeNumberName</td>
                                    <td>@item.TypeNumberList[x].DistributionBoxCount</td>
                                    <td>@item.TypeNumberList[x].DistributionCount</td>
                                    <td>@item.TypeNumberList[x].RecoveryBoxCount</td>
                                    <td>@item.TypeNumberList[x].RecoveryCount</td>
                                    <td>@item.TypeNumberList[x].GiveBoxCount</td>
                                    <td>@item.TypeNumberList[x].GiveCount</td>
                                    <td>@item.TypeNumberList[x].ExChangeBoxCount</td>
                                    <td>@item.TypeNumberList[x].ExChangeCount</td>
                                    <td>@item.TypeNumberList[x].BackBoxCount</td>
                                    <td>@item.TypeNumberList[x].BackCount</td>
                                    <td>@item.TypeNumberList[x].DamageCount</td>
                                    <td>@item.TypeNumberList[x].UnitPrice</td>
                                    <td>@item.TypeNumberList[x].Price</td>
                                }
                                else
                                {
                                    <td>@item.TypeNumberList[x].TypeNumberName</td>
                                    <td>@item.TypeNumberList[x].DistributionBoxCount</td>
                                    <td>@item.TypeNumberList[x].DistributionCount</td>
                                    <td>@item.TypeNumberList[x].RecoveryBoxCount</td>
                                    <td>@item.TypeNumberList[x].RecoveryCount</td>
                                    <td>@item.TypeNumberList[x].GiveBoxCount</td>
                                    <td>@item.TypeNumberList[x].GiveCount</td>
                                    <td>@item.TypeNumberList[x].ExChangeBoxCount</td>
                                    <td>@item.TypeNumberList[x].ExChangeCount</td>
                                    <td>@item.TypeNumberList[x].BackBoxCount</td>
                                    <td>@item.TypeNumberList[x].BackCount</td>
                                    <td>@item.TypeNumberList[x].DamageCount</td>
                                    <td>@item.TypeNumberList[x].UnitPrice</td>
                                    <td>@item.TypeNumberList[x].Price</td>
                                }
                            </tr>
                        }

                    }
                }
                @*<tr class="footer">
                        <td style="color:red">合计</td>
                        <td colspan="6"></td>
                        <td style="color:red">@SumtotalPrice</td>
                    </tr>*@
            </tbody>
        </table>
    }
</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        共 @Model.TotalItemCount 条，  
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp; 条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&Name=@(Context.Request.Query["Name"])&PlatesNumber=@(Context.Request.Query["PlatesNumber"])&beginTime=@(Context.Request.Query["beginTime"])&endTime=@(Context.Request.Query["endTime"])" />
        @Html.PagedListPager(Model, page => Url.Action("Index", new { pageIdx = page, Name = Context.Request.Query["Name"], PlatesNumber = Context.Request.Query["PlatesNumber"], beginTime = Context.Request.Query["beginTime"], endTime = Context.Request.Query["endTime"] }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>


